﻿using System;
using System.Reflection;
using MyBasicLib.Collections.Generic;

namespace MyBasicLib.Reflection
{ 
    internal static class FastReflectionCaches
    {
       
        public static TValue Get<TKey, TValue>(TKey key, Func<TKey, TValue> create) where TKey : MemberInfo
        {
            TValue value = FastReflectionCache<TKey, TValue>.Instance.FetchOrCreateItem(key, create);
            return value;
        }
    }

    internal static class FastReflectionCache<TKey, TValue>
        where TKey : MemberInfo
    {
        public static readonly ICache<TKey, TValue> Instance =
            new ReaderWriterCache<TKey, TValue>(MemberInfoComparer<TKey>.Default);
          //  new SlidingExpirationCache<TKey, TValue>(MemberInfoComparer<TKey>.Default, TimeSpan.FromHours(1));
    }//SimpleCache, TimeSpan.FromHours(1)SlidingExpirationCache
}